package org.example.medical.service.impl;

import org.example.medical.Mapper.DiagnosisRecordMapper;
import org.example.medical.entity.DiagnosisRecord;
import org.example.medical.service.DiagnosisRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DiagnosisRecordServiceImpl implements DiagnosisRecordService {
    @Autowired
    private DiagnosisRecordMapper diagnosisRecordMapper;
    @Override
    public List<DiagnosisRecord> getDiagnosisRecords(String patientName, String diseaseName, String status, String diagnosisTime, int page, int size) {
        int offset = (page - 1) * size;
        return diagnosisRecordMapper.selectByPageAndFilters(
                patientName,
                diseaseName,
                status,
                diagnosisTime,
                offset,
                size
        );
    }

    @Override
    public void addDiagnosisRecord(DiagnosisRecord diagnosisRecord) {
        diagnosisRecordMapper.insertDiagnosisRecord(diagnosisRecord);

    }

    @Override
    public void updateDiagnosisRecord(DiagnosisRecord diagnosisRecord) {
        diagnosisRecordMapper.updateDiagnosisRecord(diagnosisRecord);

    }

    @Override
    public void softDeleteDiagnosisRecord(Long diagnosisId) {
        diagnosisRecordMapper.softDeleteDiagnosisRecord(diagnosisId);

    }

    @Override
    public void batchSoftDeleteDiagnosisRecords(List<Long> diagnosisIds) {
        diagnosisRecordMapper.batchSoftDeleteDiagnosisRecords(diagnosisIds);

    }
}
